package me.sdau.spider.kafkaprocess.kafka.nlp.sdk;

import com.alibaba.fastjson.JSONObject;
import com.bonc.text.sdk.client.TextSentimentAnalysisClient;

/**
 * @author zj
 * @date 2018/4/3 14:47
 */
public class NegativeScore implements NlpMethod {
    private TextSentimentAnalysisClient instance = TextSentimentAnalysisClient.getIntance();

    @Override
    public String get(String title, String content) {
        JSONObject json = JSONObject.parseObject(getJson(title, content));
        String score = json.getString("score");
        return score == null ? "0" : score;
    }

    @Override
    public String getJson(String title, String content) {
        instance.setDomain("172.16.23.13:9187");
        return instance.getTextScore(content);
    }
}
